Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

281
Views
MongoDB | discord.js Add-Money Command Not Working

i am making A Discord.js Add-money command but its having a Wierd bug, Whever i execute this command ?add-money 1 then it perfectly works fine but when i execute it again by typing ?add-money 1 then instead of it to make my balance to 2 it makes it to 11 which literally makes no Sense, please help with my problem.

here is the code:

const { MessageEmbed, MessageButton, MessageActionRow } = require(`discord.js`);
const ee = require(`../../botconfig/embed.json`);
const User = require("../../models/user.js")
module.exports = {
    name: `add-money`,
    run: async (client, message, args) => {
       if(!message.member.permissions.has("ADMINISTRATOR") return message.channel.send("You Dont Have Required Perms to Run This Command!")
        let user = await User.findOne({ id: message.author.id })
        if(!user) return message.channel.send(`You Dont own a Account yet!`)
        let amount = args[0]
          if(Number.isNaN(+amount)) return message.channel.send(`The amount is Not A Number!`)
          user.coins = user.coins + amount
          await user.save()
          return message.channel.send(`You added ${amount} to your balance!`)
    }
}

Here is My Mongoose Model:

const mongoose = require("mongoose");

const UserSchema = new mongoose.Schema({
    id: { type: String, required: true },
    coins: { type: Number, default: 0 },
});

module.exports = mongoose.model("User", UserSchema);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

user.coins += Math.floor(amount)
await user.save();
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!